import { tenantHttp } from '../../../utils/http/axios/index';

interface AppListWithSfs {
  id: string;
  createdTime: string;
  createdBy: string;
  lastUpdateTime: string;
  lastUpdateBy: string;
  isDel: boolean;
  name: string;
  logo: string;
  idaasAppId: string;
  idaasClientId: string;
  idaasClientSecret?: any;
  type: string;
  domain: string;
  appId: string;
  effectiveTime?: any;
  expireTime?: any;
  status?: any;
  architecture?: any;
  sfsResourceList: any[];
  sfsResourceNum: number;
  console: boolean;
}

interface SfsList {
  records: any[];
  total: number;
  size: number;
  current: number;
  orders: any[];
  optimizeCountSql: boolean;
  searchCount: boolean;
  countId?: any;
  maxLimit?: any;
  pages: number;
}

enum Api {
  GET_ALL_APP = '/app/listAllSubAppAndFs',
  GET_SFS_LIST = '/app/getFileSystemListByPage',
  EXPAND_SFS_TURBO = '/deployment/addSfsTurboAction',
  CHECK_EXPANSION_STATUS = '/deployment/getSfsTurboAddActionStatus',
  CREATE_SFS_TURBO = '/deployment/createSfsTurbo',
}

export const getAllApp = () => {
  // App展示页，不分页获取应用列表
  return tenantHttp.get<AppListWithSfs[]>({ url: Api.GET_ALL_APP });
};
export const getSfsList = (data?: { current: number; size: number; model: string }) => {
  // 分页查看文件系统列表（租户侧）
  return tenantHttp.post<SfsList>({ url: Api.GET_SFS_LIST, data });
};
export const expandSfsTurobo = (params?: { appId: string; sfsUUid: string; size: number }) => {
  // 扩容文件系统
  return tenantHttp.get<boolean>({ url: Api.EXPAND_SFS_TURBO, params });
};
export const checkExpansionStatus = (params?: { sfsUUid: string }) => {
  // 查看扩容状态是否成功的接口
  return tenantHttp.get<boolean>({ url: Api.CHECK_EXPANSION_STATUS, params });
};
export const createSfsTurbo = (params?: {
  appId: string;
  tenantCode: string;
  shareProto: string;
  num: number;
  size: number;
}) => {
  return tenantHttp.post<boolean>({ url: Api.CREATE_SFS_TURBO, params });
};
